home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1993 July / InfoMagic USENET CD-ROM July 1993.ISO / sources / misc / volume7 / dbug-man < prev    next >
Encoding:
Text File  |  1989-07-21  |  17.1 KB  |  615 lines

  1. Newsgroups: comp.sources.misc
  2. subject: v07i098: Man pages for DBUG package
  3. from: allbery@uunet.UU.NET (Brandon S. Allbery - comp.sources.misc)
  4. Reply-To: kap121%ztivax@ztivax.siemens.com (Thomas Oeser)
  5.  
  6. Posting-number: Volume 7, Issue 98
  7. Submitted-by: kap121%ztivax@ztivax.siemens.com (Thomas Oeser)
  8. Archive-name: dbug-man
  9.  
  10. [[Note:  these are neither a patch to nor an official part of the DBUG
  11.   package.  ++bsa]]
  12.  
  13. enclosed you find two man pages for the recently distributed DBUG package.
  14. I've picked up some information found in the source files and user's
  15. documentation and put them together to the man pages.
  16.  
  17. I hope this is a start to make a more complete and accurate version of them.
  18.  
  19. Thomas Oeser
  20. ------------------------------------------------------------------------------
  21. ARPA:        kap121@ztivax.siemens.com
  22. UUCP:        kap121@ztivax.uucp (may work only in Europe...)
  23. Postal mail:    Siemens AG, K Sys Ap 121, Otto-Hahn-Ring 6, P.O. Box 830951,
  24.         D-8000 Munich 83, West Germany
  25. Phone:        + 49 (89) 636-47537
  26. FAX:        + 49 (89) 636-41477
  27.  
  28. Disclaimer:
  29. The opinions expressed are my own, and should not be attributed to anyone else
  30. living or dead.
  31. ------------------------------------------------------------------------------
  32.  
  33.  
  34. #---------- cut here ---------- cut here ----------- cut here -----------------
  35. #! /bin/sh
  36. # This is a shell archive.  Remove anything before this line, then feed it
  37. # into a shell via "sh file" or similar.  To overwrite existing files,
  38. # type "sh file -c".
  39. # The tool that generated this appeared in the comp.sources.unix newsgroup;
  40. # send mail to comp-sources-unix@uunet.uu.net if you want that tool.
  41. # If this archive is complete, you will see the following message at the end:
  42. #        "End of shell archive."
  43. # Contents:  analyze.man dbug.man
  44. # Wrapped by email@perlach on Thu Jul 20 09:10:09 1989
  45. PATH=/bin:/usr/bin:/usr/ucb ; export PATH
  46. if test -f 'analyze.man' -a "${1}" != "-c" ; then 
  47.   echo shar: Will not clobber existing file \"'analyze.man'\"
  48. else
  49. echo shar: Extracting \"'analyze.man'\" \(1714 characters\)
  50. sed "s/^X//" >'analyze.man' <<'END_OF_FILE'
  51. X.\" SCCSID = @(#)analyze.man    1.1
  52. X.\"
  53. X.TH ANALYZE 1L "89/07/20" "K Sys Ap 121"
  54. X.SH NAME
  55. Xanalyze \- analyzes the profile file written out by the dbug
  56. Xroutines with profiling enabled.
  57. X.SH SYNOPSIS
  58. X\fIanalyze\fP [-v] [profileFile]
  59. X.ad
  60. X.SH DESCRIPTION
  61. X\fIAnalyze\fP will read an trace file created by the dbug package
  62. X(when run with traceing enabled).  It will then produce a
  63. Xsummary on standard output listing the name of each traced
  64. Xfunction, the number of times it was called, the percentage
  65. Xof total calls, the time spent executing the function, the
  66. Xproportion of the total time and the 'importance'.  The last
  67. Xis a metric which is obtained by multiplying the proportions
  68. Xof calls and the proportions of time for each function.  The
  69. Xgreater the importance, the more likely it is that a speedup
  70. Xcould be obtained by reducing the time taken by that function.
  71. X.PP
  72. XNote that the timing values that you obtain are only rough
  73. Xmeasures.  The overhead of the dbug package is included
  74. Xwithin.  However, there is no need to link in special profiled
  75. Xlibraries and the like.
  76. X.SH OPTIONS
  77. X\fIAnnalize\fP accepts the following command line options:
  78. X.TP 16
  79. X-v
  80. XIf this option is specified, the output of this program will be a verbose
  81. Xtable. By default, the output of this program will look very similar to
  82. XUnix profiler.
  83. X.TP 16
  84. XprofileFile
  85. XSpecifies the the name of file containing the input data to be examined
  86. X(default: dbugmon.out).
  87. X.SH USAGE
  88. XThis should be easy :-).
  89. X.SH FILES
  90. Xdbugmon.out
  91. X.SH "SEE ALSO"
  92. Xdbug(3L)
  93. X.SH ENVIRONMENT
  94. Xnone
  95. X.SH BUGS
  96. XThere still are some.
  97. X.SH COPYRIGHT
  98. Xnone
  99. X.SH AUTHORS
  100. XFred Fish, Binayak Banerjee
  101. X.br
  102. XEnhanced Software Technologies, Tempe, AZ
  103. X.br
  104. Xasuvax!mcdphx!estinc!fnf, seismo!bpa!sjuvax!bbanerje
  105.  
  106. END_OF_FILE
  107. echo shar: NEWLINE appended to \"'analyze.man'\"
  108. if test 1715 -ne `wc -c <'analyze.man'`; then
  109.     echo shar: \"'analyze.man'\" unpacked with wrong size!
  110. fi
  111. # end of 'analyze.man'
  112. fi
  113. if test -f 'dbug.man' -a "${1}" != "-c" ; then 
  114.   echo shar: Will not clobber existing file \"'dbug.man'\"
  115. else
  116. echo shar: Extracting \"'dbug.man'\" \(12580 characters\)
  117. sed "s/^X//" >'dbug.man' <<'END_OF_FILE'
  118. X.\" SCCSID = @(#)dbug.man    1.1
  119. X.\"
  120. X.TH DBUG 3L "89/07/20" "K Sys Ap 121"
  121. X.SH NAME
  122. Xdbug \- a toolset for internal debugging of C programs.
  123. X.ad
  124. X.SH SYNOPSIS
  125. XNote, the following "functions" are C macros. Therefore, the description of
  126. Xthe parameters are not necessarily correct C. The intention is, to describe as
  127. Xclose as possible but shortly what type of "data" can be used for the
  128. Xparameters of the macros.
  129. X.PP
  130. X#include <dbug.h>
  131. X.PP
  132. X\fIDBUG_ENTER\fP ( aName )
  133. X.RS 6
  134. Xchar *    aName;
  135. X.RS -6
  136. X.PP
  137. X\fIDBUG_RETURN\fP ( aValue )
  138. X.RS 6
  139. Xint    aValue;
  140. X.RS -6
  141. X.PP
  142. X\fIDBUG_VOID_RETURN\fP
  143. X.PP
  144. X\fIDBUG_PRINT\fP ( aLabelString, (thePrintfParameters) )
  145. X.RS 6
  146. Xchar *    aLabelString;
  147. X.br
  148. XParameterList thePrintfParameters;
  149. X.RS -6
  150. X.PP
  151. X\fIDBUG_PROCESS\fP ( aName )
  152. X.RS 6
  153. Xchar *    aName;
  154. X.RS -6
  155. X.PP
  156. X\fIDBUG_PUSH\fP ( aDbugOptionString )
  157. X.RS 6
  158. Xchar *    aDbugOptionString;
  159. X.RS -6
  160. X.PP
  161. X\fIDBUG_POP\fP ()
  162. X.PP
  163. X\fIDBUG_FILE\fP
  164. X.PP
  165. X\fIDBUG_EXECUTE\fP ( aLabelString, someCode )
  166. X.RS 6
  167. Xchar *    aLabelString;
  168. X.br
  169. XC-Code    someCode;
  170. X.RS -6
  171. X.PP
  172. X\fIDBUG_SETJMP\fP ( env )
  173. X.RS 6
  174. Xjmp_buf    env;
  175. X.RS -6
  176. X.PP
  177. X\fIDBUG_LONGJMP\fP ( env, val )
  178. X.RS 6
  179. Xjmp_buf    env;
  180. X.br
  181. Xint    val;
  182. X.RS -6
  183. X.SH DESCRIPTION
  184. X\fIDbug\fP is
  185. Xa macro based C internal debugging
  186. Xpackage which has proven to be a very flexible and useful tool
  187. Xfor debugging, testing, and porting C programs.
  188. X.PP
  189. XInternal debugging are typically "print statements" included into the program
  190. Xsource. \fIDbug\fP provides for enhanced capabilities to do so. In addition
  191. Xeach capability can be individually enabled or disabled at the time a program
  192. Xis invoked by specifying the appropriate command line arguments.
  193. X.PP
  194. XSo, all of the features of the
  195. X.I dbug
  196. Xpackage can be enabled or disabled dynamically at execution time.
  197. XThis means that production programs will run normally when
  198. Xdebugging is not enabled, and eliminates the need to maintain two
  199. Xseparate versions of a program.
  200. X.PP
  201. XThe following specifies a summary of the \fIdbug\fP capabilities:
  202. X.TP 3
  203. X-
  204. XExecution trace showing function level control flow in a
  205. Xsemi-graphically manner using indentation to indicate nesting
  206. Xdepth.
  207. X.TP 3
  208. X-
  209. XOutput the values of all, or any subset of, key internal variables.
  210. X.TP 3
  211. X-
  212. XLimit actions to a specific set of named functions.
  213. X.TP 3
  214. X-
  215. XLimit function trace to a specified nesting depth.
  216. X.TP 3
  217. X-
  218. XLabel each output line with source file name and line number.
  219. X.TP 3
  220. X-
  221. XLabel each output line with name of current process.
  222. X.TP 3
  223. X-
  224. XPush or pop internal debugging state to allow execution with
  225. Xbuilt in debugging defaults.
  226. X.TP 3
  227. X-
  228. XRedirect the debug output stream to standard output (stdout)
  229. Xor a named file.
  230. XThe default output stream is standard error (stderr).
  231. X.PP
  232. XMany of the things easily accomplished with conventional debugging
  233. Xtools, such as symbolic debuggers, are difficult or impossible with this
  234. Xpackage, and vice versa.
  235. XThus the
  236. X.I dbug
  237. Xpackage should 
  238. X.I not
  239. Xbe thought of as a replacement or substitute for
  240. Xother debugging tools, but simply as a useful
  241. X.I addition
  242. Xto the
  243. Xprogram development and maintenance environment.
  244. X.PP
  245. XThe
  246. X.I dbug
  247. Xpackage imposes only a slight speed penalty on executing
  248. Xprograms, typically much less than 10 percent, and a modest size
  249. Xpenalty, typically 10 to 20 percent.
  250. XBy defining a specific C preprocessor symbol both of these
  251. Xcan be reduced to zero with no changes required to the
  252. Xsource code.
  253. X.PP
  254. XNotice, that all of the debugger functions are implemented
  255. Xvia preprocessor macros.
  256. XThis does not detract from the readability of the code and makes disabling
  257. Xall debug compilation trivial (a single preprocessor symbol, 
  258. X.B DBUG_OFF ,
  259. Xforces the macro expansions to be null).
  260. X.SH "SUMMARY OF MACROS"
  261. XThis summarizes the usage of all currently defined macros
  262. Xin the 
  263. X.I dbug
  264. Xpackage.
  265. XThe macros definitions are found in the user include file
  266. X.B dbug.h
  267. Xfrom the standard include directory.
  268. X.TP 15
  269. XDBUG_ENTER 
  270. XUsed to tell the runtime support module the name of the function
  271. Xbeing entered.
  272. XThe argument must be of type "pointer to character".
  273. XThe 
  274. XDBUG_ENTER
  275. Xmacro must precede all executable lines in the
  276. Xfunction just entered, and must come after all local declarations.
  277. XEach 
  278. XDBUG_ENTER
  279. Xmacro must have a matching 
  280. XDBUG_RETURN 
  281. Xor
  282. XDBUG_VOID_RETURN
  283. Xmacro 
  284. Xat the function exit points.
  285. XDBUG_ENTER 
  286. Xmacros used without a matching 
  287. XDBUG_RETURN 
  288. Xor 
  289. XDBUG_VOID_RETURN
  290. Xmacro 
  291. Xwill cause warning messages from the 
  292. X.I dbug
  293. Xpackage runtime support module.
  294. X.br
  295. X.sp
  296. XEX:\ DBUG_ENTER\ ("main");
  297. X.TP 15
  298. XDBUG_RETURN 
  299. XUsed at each exit point of a function containing a 
  300. XDBUG_ENTER 
  301. Xmacro
  302. Xat the entry point.
  303. XThe argument is the value to return.
  304. XFunctions which return no value (void) should use the 
  305. XDBUG_VOID_RETURN
  306. Xmacro.
  307. XIt 
  308. Xis an error to have a 
  309. XDBUG_RETURN 
  310. Xor 
  311. XDBUG_VOID_RETURN 
  312. Xmacro in a function
  313. Xwhich has no matching 
  314. XDBUG_ENTER 
  315. Xmacro, and the compiler will complain
  316. Xif the macros are actually used (expanded).
  317. X.br
  318. X.sp
  319. XEX:\ DBUG_RETURN\ (value);
  320. X.br
  321. XEX:\ DBUG_VOID_RETURN;
  322. X.TP 15
  323. XDBUG_PROCESS 
  324. XUsed to name the current process being executed.
  325. XA typical argument for this macro is "argv[0]", though
  326. Xit will be perfectly happy with any other string.
  327. X.br
  328. X.sp
  329. XEX:\ DBUG_PROCESS\ (argv[0]);
  330. X.TP 15
  331. XDBUG_PUSH 
  332. XSets a new debugger state by pushing the current
  333. X.B dbug
  334. Xstate onto an
  335. Xinternal stack and setting up the new state using the debug control
  336. Xstring passed as the macro argument.
  337. XThe most common usage is to set the state specified by a debug
  338. Xcontrol string retrieved from the argument list.
  339. XNote that the leading "\-#" in a debug control string specified
  340. Xas a command line argument must
  341. X.B not
  342. Xbe passed as part of the macro argument.
  343. XThe proper usage is to pass a pointer to the first character
  344. X.B after
  345. Xthe "\-#" string.
  346. X.br
  347. X.sp
  348. XEX:\ DBUG_PUSH\ (\&(argv[i][2]));
  349. X.br
  350. XEX:\ DBUG_PUSH\ ("d:t");
  351. X.br
  352. XEX:\ DBUG_PUSH\ (" ");
  353. X.TP 15
  354. XDBUG_POP 
  355. XRestores the previous debugger state by popping the state stack.
  356. XAttempting to pop more states than pushed will be ignored and no
  357. Xwarning will be given.
  358. XThe 
  359. XDBUG_POP 
  360. Xmacro has no arguments.
  361. X.br
  362. X.sp
  363. XEX:\ DBUG_POP\ ();
  364. X.TP 15
  365. XDBUG_FILE 
  366. XThe 
  367. XDBUG_FILE 
  368. Xmacro is used to do explicit I/O on the debug output
  369. Xstream.
  370. XIt is used in the same manner as the symbols "stdout" and "stderr"
  371. Xin the standard I/O package.
  372. X.br
  373. X.sp
  374. XEX:\ fprintf\ (DBUG_FILE,\ "Doing\ my\ own\ I/O!\\n");
  375. X.TP 15
  376. XDBUG_EXECUTE 
  377. XThe DBUG_EXECUTE macro is used to execute any arbitrary C code.
  378. XThe first argument is the debug keyword, used to trigger execution
  379. Xof the code specified as the second argument.
  380. XThis macro must be used cautiously because, like the 
  381. XDBUG_PRINT 
  382. Xmacro,
  383. Xit is automatically selected by default whenever the 'd' flag has
  384. Xno argument list (I.E., a "\-#d:t" control string).
  385. X.br
  386. X.sp
  387. XEX:\ DBUG_EXECUTE\ ("abort",\ abort\ ());
  388. X.TP 15
  389. XDBUG_N
  390. XThese macros, where N is in the range 2\-5, are currently obsolete
  391. Xand will be removed in a future release.
  392. XUse the new DBUG_PRINT macro.
  393. X.TP 15
  394. XDBUG_PRINT
  395. XUsed to do printing via the "fprintf" library function on the
  396. Xcurrent debug stream,
  397. XDBUG_FILE.
  398. XThe first argument is a debug keyword, the second is a format string
  399. Xand the corresponding argument list.
  400. XNote that the format string and argument list are all one macro argument
  401. Xand
  402. X.B must
  403. Xbe enclosed in parenthesis.
  404. X.br
  405. X.sp
  406. XEX:\ DBUG_PRINT\ ("eof",\ ("end\ of\ file\ found"));
  407. X.br
  408. XEX:\ DBUG_PRINT\ ("type",\ ("type\ is\ %x",\ type));
  409. X.br
  410. XEX:\ DBUG_PRINT\ ("stp",\ ("%x\ \->\ %s",\ stp,\ stp\ \->\ name));
  411. X.TP 15
  412. XDBUG_SETJMP
  413. XUsed in place of the setjmp() function to first save the current
  414. Xdebugger state and then execute the standard setjmp call.
  415. XThis allows the debugger to restore its state when the
  416. XDBUG_LONGJMP macro is used to invoke the standard longjmp() call.
  417. XCurrently all instances of DBUG_SETJMP must occur within the
  418. Xsame function and at the same function nesting level.
  419. X.br
  420. X.sp
  421. XEX:\ DBUG_SETJMP\ (env);
  422. X.TP 15
  423. XDBUG_LONGJMP
  424. XUsed in place of the longjmp() function to first restore the
  425. Xprevious debugger state at the time of the last DBUG_SETJMP
  426. Xand then execute the standard longjmp() call.
  427. XNote that currently all DBUG_LONGJMP macros restore the state
  428. Xat the time of the last DBUG_SETJMP.
  429. XIt would be possible to maintain separate DBUG_SETJMP and DBUG_LONGJMP
  430. Xpairs by having the debugger runtime support module use the first
  431. Xargument to differentiate the pairs.
  432. X.br
  433. X.sp
  434. XEX:\ DBUG_LONGJMP\ (env,val);
  435. X.SH "DEBUG CONTROL STRING"
  436. XThe debug control string is used to control the "behaviour" of the dbug macros,
  437. Xwhen running the application. The \fIdebug control string\fP is passed to the
  438. X\fIdbug\fP package via the \fIDBUG_PUSH()\fP macro (note, that the parameter of
  439. Xthis macro may be the value of a program argument; see example above).
  440. X.PP
  441. XThe following list summarizes the currently available debugger options
  442. Xand the flag characters which enable or disable them. Debugger options may be
  443. Xconcatenated to a \fIdebug control string\fP using the ":" (colon) as a
  444. Xseperator (e.g., <option1>:<option2>:...:<optionN>).
  445. X.PP
  446. XArgument lists enclosed in '[' and ']' are optional.
  447. X.TP 15
  448. Xd[,keywords]
  449. XEnable output from macros with specified keywords.
  450. XA null list of keywords implies that all keywords are selected.
  451. X.TP 15
  452. XD[,time]
  453. XDelay for specified time after each output line, to let output drain.
  454. XTime is given in tenths of a second (value of 10 is one second).
  455. XDefault is zero.
  456. X.TP 15
  457. Xf[,functions]
  458. XLimit debugger actions to the specified list of functions.
  459. XA null list of functions implies that all functions are selected.
  460. X.TP 15
  461. XF
  462. XMark each debugger output line with the name of the source file
  463. Xcontaining the macro causing the output.
  464. X.TP 15
  465. Xg
  466. XTurn on machine independent profiling.
  467. XA profiling data collection file, named dbugmon.out, will be written
  468. Xfor postprocessing by the "analyze(1L)" program.
  469. XThe accuracy of this feature is relatively unknown at this time.
  470. X.TP 15
  471. Xi
  472. XIdentify the process emitting each line of debug or trace output
  473. Xwith the process id for that process.
  474. X.TP 15
  475. XL
  476. XMark each debugger output line with the source file line number of
  477. Xthe macro causing the output.
  478. X.TP 15
  479. Xn
  480. XMark each debugger output line with the current function nesting depth.
  481. X.TP 15
  482. XN
  483. XSequentially number each debugger output line starting at 1.
  484. XThis is useful for reference purposes when debugger output is
  485. Xinterspersed with program output.
  486. X.TP 15
  487. Xo[,file]
  488. XRedirect the debugger output stream to the specified file.
  489. XThe default output stream is stderr.
  490. XA null argument list causes output to be redirected to stdout.
  491. X.TP 15
  492. Xp[,processes]
  493. XLimit debugger actions to the specified processes.
  494. XA null list implies all processes.
  495. XThis is useful for processes which run child processes.
  496. XNote that each debugger output line can be marked with the name of
  497. Xthe current process via the 'P' flag.
  498. XThe process name must match the argument passed to the
  499. X.B DBUG_PROCESS
  500. Xmacro.
  501. X.TP 15
  502. XP
  503. XMark each debugger output line with the name of the current process
  504. Xfrom argv[0].
  505. XMost useful when used with a process which runs child processes that
  506. Xare also being debugged.
  507. XNote that the parent process must arrange for the debugger control
  508. Xstring to be passed to the child processes.
  509. X.TP 15
  510. Xr
  511. XUsed in conjunction with the 
  512. X.B DBUG_PUSH 
  513. Xmacro to reset the current
  514. Xindentation level back to zero.
  515. XMost useful with 
  516. X.B DBUG_PUSH 
  517. Xmacros used to temporarily alter the
  518. Xdebugger state.
  519. X.TP 15
  520. Xt[,N]
  521. XEnable function control flow tracing.
  522. XThe maximum nesting depth is specified by N, and defaults to
  523. X200.
  524. X.SH USAGE
  525. XThe following example shows a very simple use of the \fIdbug\fP facilities.
  526. X.PP
  527. XFirst, the source code including some \fIdbug\fP statements is given:
  528. X.RS 12
  529. X.sp
  530. X.nf
  531. X#include <stdio.h>
  532. X#include <dbug.h>
  533. X
  534. Xmain (argc, argv)
  535. Xint argc;
  536. Xchar *argv[];
  537. X{
  538. X    int i;
  539. X    int atoi();
  540. X
  541. X    DBUG_ENTER ("main");
  542. X    DBUG_PROCESS (argv[0]);
  543. X
  544. X    for (i = 1; i < argc && argv[i][0] == '-'; i++) {
  545. X    switch (argv[i][1]) {
  546. X        case '#':
  547. X        DBUG_PUSH (&(argv[i][2]));
  548. X        break;
  549. X    }
  550. X    }
  551. X
  552. X    for (; i < argc; i++) {
  553. X    DBUG_PRINT ("args", ("argv[%d] = %s", i, argv[i]));
  554. X    printf ("%F\\n", 1.0/atoi(argv[i]));
  555. X    }
  556. X
  557. X    DBUG_RETURN (0);
  558. X}
  559. X.fi
  560. X.sp
  561. X.RS -12
  562. X.PP
  563. XThe following invocation of the program "inverse" compiled from the source
  564. Xabove would cause the corresponding outputs:
  565. X.RS 12
  566. X.sp
  567. X.nf
  568. X$ inverse\ \ 2 4
  569. X0.5
  570. X0.25
  571. X
  572. X$ inverse -#t\ \ 2 4
  573. X|
  574. X0.5
  575. X0.25
  576. X< main
  577. X
  578. Xinverse -#d:t\ \ 2 4
  579. X| args: argv[2] = 2
  580. X0.5
  581. X| args: argv[3] = 4
  582. X0.25
  583. X< main
  584. X.fi
  585. X.sp
  586. X.RS -12
  587. X.SH FILES
  588. X/LocalTools/lib/local/libdbug.a
  589. X/LocalTools/include/local/dbug.h
  590. X.SH "SEE ALSO"
  591. XDBUG Users Manual, analyze(1L)
  592. X.SH ENVIRONMENT
  593. Xnone
  594. X.SH BUGS
  595. XThere still are some.
  596. X.SH COPYRIGHT
  597. Xnone
  598. X.SH AUTHORS
  599. XFred Fish, Binayak Banerjee
  600. X.br
  601. XEnhanced Software Technologies, Tempe, AZ
  602. X.br
  603. Xasuvax!mcdphx!estinc!fnf, seismo!bpa!sjuvax!bbanerje
  604.  
  605. END_OF_FILE
  606. echo shar: NEWLINE appended to \"'dbug.man'\"
  607. if test 12581 -ne `wc -c <'dbug.man'`; then
  608.     echo shar: \"'dbug.man'\" unpacked with wrong size!
  609. fi
  610. # end of 'dbug.man'
  611. fi
  612. echo shar: End of shell archive.
  613. exit 0
  614.  
  615.